gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\pca\kpcademo1.m

    echo on;
% KPCADEMO1 demo on the Kernel-PCA.

% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Modifications:
% 8-July-2001, V.Franc 

% First, we load data from file. Use 'creatset' to interactively 
% create your own data in 2D.
pause;  % press anykey

data=load('pcaexam1');

% The Kernel-PCA non-linearly map the data into high dimensional 
% space and then reduces their dimension by linear (standard) PCA.
%
% The points in the original space which have the equal value of 
% extracted feature form contours. The contours show main variance 
% in the data. These contours can be displayed by pkernelpca function.
% 
% We display two features of the original 2D space and then
% two features (principal components) after linear, RBF (sigma =1)
% and polynomial (d=2) mapping. The first component si denoted by
% red and the second by blue color.
pause;  % press anykey

% Plot the points with the equal coordinates x and y
figure;
subplot(2,2,1);
hold on;
ppoints(data.X,data.I);                
title('Orginal space');

w = axis;
for i = w(1):(w(2)-w(1))/8:w(2),   
   plot([i i],[w(3),w(4)],color(1));
   echo off;
end
for j = w(3):(w(4)-w(3))/8:w(4),
   plot([w(1) w(2)],[j j],color(2));
end
echo on;

% Linear PCA
subplot(2,2,2);
hold on;
ppoints(data.X,data.I);        % display data
title('Linear PCA');
pkernelpca(data.X,[1,2],'linear',[]);

% RBF mapping, PCA
subplot(2,2,3);
hold on;
ppoints(data.X,data.I);        % display data
title('RBF(sigma = 1), PCA');
pkernelpca(data.X,[1,2],'rbf',[0.5]);

% Polynomial mapping, PCA
subplot(2,2,4);
hold on;
ppoints(data.X,data.I);        % display data
title('Polynom (d = 2), PCA');
pkernelpca(data.X,[1,2],'poly',[2]);

echo off;